label: Remove a double if (needs_root) check
authorTimm Bäder <mail@baedert.org>
Fri, 10 Apr 2020 14:23:32 +0000 (16:23 +0200)
committerTimm Bäder <mail@baedert.org>
Fri, 17 Apr 2020 13:21:00 +0000 (15:21 +0200)
The code is clearer and shorter this way.

gtk/gtklabel.c

index 62d297285cd82644425a98bbe797d9bd50b39d7e..5caf2ea1d0cbe11f7bc9e31f0658b27eb0b2121b 100644 (file)
@@ -2224,8 +2224,7 @@ parse_uri_markup (GtkLabel      *label,
                   GError       **error)
 {
   GMarkupParseContext *context = NULL;
-  const gchar *p, *end;
-  gboolean needs_root = TRUE;
+  const char *p, *end;
   gsize length;
   UriParserData pdata;
 
@@ -2241,22 +2240,21 @@ parse_uri_markup (GtkLabel      *label,
   while (p != end && xml_isspace (*p))
     p++;
 
-  if (end - p >= 8 && strncmp (p, "<markup>", 8) == 0)
-    needs_root = FALSE;
-
   context = g_markup_parse_context_new (&markup_parser, 0, &pdata, NULL);
 
-  if (needs_root)
+  if (end - p >= 8 && strncmp (p, "<markup>", 8) == 0)
     {
-      if (!g_markup_parse_context_parse (context, "<markup>", -1, error))
+      if (!g_markup_parse_context_parse (context, str, length, error))
         goto failed;
     }
+  else
+    {
+      if (!g_markup_parse_context_parse (context, "<markup>", -1, error))
+        goto failed;
 
-  if (!g_markup_parse_context_parse (context, str, length, error))
-    goto failed;
+      if (!g_markup_parse_context_parse (context, str, length, error))
+        goto failed;
 
-  if (needs_root)
-    {
       if (!g_markup_parse_context_parse (context, "</markup>", -1, error))
         goto failed;
     }